package com.tanhua.server.interceptor;

import com.tanhua.server.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置类，所有定义的拦截器都要在这里注册
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    // 注入拦截器
    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry
                .addInterceptor(tokenInterceptor)
                .excludePathPatterns("/user/login","/user/loginVerification")
                .addPathPatterns("/**"); // 指定拦截的资源，拦截所有资源  /user/a/b
    }
}
